﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBHelper;
using System.Data.SqlClient;
using System.Data;
using BusinessLayer.FindArtInfo.Models;

namespace BusinessLayer.FindArtInfo
{
    public class CountryBL
    {
        private readonly DbHelper _db;

        public CountryBL()
        {
            _db = new DbHelper(new DbConfig().DbFindArtInfoConnectionString);         
        }

        public List<CountryModel> GetAll()
        {
            var oCommand = new SqlCommand("sp_Country_Select_All") { CommandType = CommandType.StoredProcedure };            
            var listCountry = _db.GetList<CountryModel>(oCommand);
            return listCountry; 
        }

        public CountryModel GetById(int id)
        {
            var oCommand = new SqlCommand("sp_Country_GetById") { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@Id", id));  
            var listCountry = _db.GetList<CountryModel>(oCommand);
            return listCountry.FirstOrDefault();
        }
    }
}
